/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef PL_TYPES_H
#define PL_TYPES_H

#if defined __cplusplus
namespace std {
#endif

/**
 * Define an 8bit signed integer type.
 */
typedef signed char         int8_t;

/**
 * Define an character type.
 */
typedef char				 CHAR;
typedef CHAR				 TCHAR;
typedef const CHAR			*LPCSTR;
typedef const TCHAR			*LPCTSTR;

/**
 * Define a wchar_t type.
 */
/*typedef wchar_t			 WCHAR;
typedef WCHAR				 OLECHAR;
typedef const WCHAR			*LPCWSTR;
typedef OLECHAR				*BSTR;
typedef const OLECHAR		*LPCOLESTR;
typedef OLECHAR				*LPOLESTR;*/

/**
 * Define an 8bit unsigned integer type.
 */
typedef unsigned char        uint8_t;
typedef unsigned char		 UCHAR;
typedef unsigned char		 BYTE;

/**
 * Define an 16bit signed integer type.
 */
typedef signed short         int16_t;
typedef short				 SHORT;
typedef short				 VARIANT_BOOL;

/**
 * Define an 16bit unsigned integer type.
 */
typedef unsigned short       uint16_t;
typedef unsigned short		 USHORT;
typedef unsigned short		 WORD;

/**
 * Define a integer type.
 */
typedef int					 plint;
typedef int					 INT;

/**
 * Define a unsigned integer type.
 */
typedef unsigned int         pluint;
typedef unsigned int         uint;
typedef unsigned int		 UINT;

/**
 * Define a long type.
 */
typedef long				 LONG;

/**
 * Define a 32bit signed integer type.
 */
typedef signed long          int32_t;
typedef int32_t				 INT32;
typedef LONG				 SCODE;

/**
 * Define a 32bit unsigned integer type.
 */
typedef unsigned long        uint32_t;
typedef uint32_t			 UINT32;
typedef unsigned long		 ULONG;
typedef unsigned long		 DWORD;
typedef ULONG				 PROPID;

/**
 * Define a 64bit signed integer type.
 */
typedef signed long long     int64_t;
typedef int64_t				 LONGLONG;

/**
 * Define a 64bit unsigned integer type.
 */
typedef unsigned long long   uint64_t;
typedef uint64_t			 ULONGLONG;

/**
 * Define ssize_t.
 */
typedef int32_t              ssize_t;

/**
 * Define size_t.
 */
typedef uint32_t             size_t;

/**
 * Define a signed integer type for pointer arithmetic.
 */
typedef int32_t              intptr_t;

/**
 * Define an unsigned integer type for pointer arithmetic.
 */
typedef uint32_t             uintptr_t;

/**
 * Define a unsigned integer type for physical pointer arithmetic.
 */
typedef uint32_t             physical_uintptr_t;

/**
 * Define a unsigned integer type for physical pointer arithmetic.
 */
typedef intptr_t             ptrdiff_t;

/**
 * Define an unsigned integer type for the processor registers.
 */
typedef uint32_t             processor_register_t;

/**
 * Define an I/O port type.
 */
typedef uint16_t             io_port_t;

/**
 * Define a type for IRQ identifications.
 */
typedef uint8_t              irq_id_t;

typedef struct LARGE_INTEGER { LONGLONG QuadPart; } LARGE_INTEGER;
typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;

#define HRESULT LONG
#define FAILED(Status) ((HRESULT)(Status)<0)

#define S_OK						((HRESULT)0x00000000L)
#define S_FALSE						((HRESULT)0x00000001L)
#define E_NOINTERFACE				((HRESULT)0x80004002L)
#define E_ABORT						((HRESULT)0x80004004L)
#define E_FAIL						((HRESULT)0x80004005L)
#define STG_E_INVALIDFUNCTION		((HRESULT)0x80030001L)
#define E_OUTOFMEMORY				((HRESULT)0x8007000EL)
#define E_INVALIDARG				((HRESULT)0x80070057L)

#define VARIANT_TRUE ((VARIANT_BOOL)-1)
#define VARIANT_FALSE ((VARIANT_BOOL)0)

/**
 * Define the size of one physical page.
 */
#define PAGE_SIZE 4096

#if defined __cplusplus
}
#endif

#endif

/* TODO define more windows things. */
/*typedef struct _FILETIME
{
	DWORD dwLowDateTime;
	DWORD dwHighDateTime;
}FILETIME;*/
